local tunan = fk.CreateSkill {

  name = "joy__tunan",

  tags = {  },

}



tunan:addEffect("active", {
  name = "joy__tunan",
  anim_type = "support",
  card_num = 0,
  min_target_num = 1,
  max_target_num = 2,
  prompt = "#joy__tunan",
  can_use = function(self, player)
    return player:usedSkillTimes(tunan.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    return #selected < 2 
  end,
  on_use = function(self, room, effect)
    for _, pid in ipairs(effect.tos) do
        local target = room:getPlayerById(pid)
        local cards = room:getNCards(1)
        local card = Fk:getCardById(cards[1])
        local choices = {}  --选项一无距离限制，选项二有距离限制，不能用interaction……
        if U.getDefaultTargets(target, card, false, true) then
            table.insert(choices, "tunan1:::"..card:toLogString())
        end
        local slash = Fk:cloneCard("slash")
        slash.skillName = tunan.name
        slash:addSubcard(card)
        if U.getDefaultTargets(target, slash, true, false) then
        table.insert(choices, "tunan2:::"..card:toLogString())
        end
        if #choices == 0 then
        table.insert(room.draw_pile, 1, cards[1])
        return
        end
        local choice = room:askForChoice(target, choices, tunan.name, nil, nil,
        {"tunan1:::"..card:toLogString(), "tunan2:::"..card:toLogString()})
        local success, dat
        if choice[6] == "1" then
        room:askForUseRealCard( target, cards, ".", tunan.name, nil, {expand_pile = cards, bypass_distances = true}, false, false)
        else
        U.askForUseVirtualCard(room, target, "slash", cards, tunan.name, "#tunan2-use:::"..card:toLogString(), false, true, false, true)
        end
    end
  end,
})

return tunan